package view
{
	import com.greensock.easing.Cubic;
	import com.greensock.greensock.TweenLite;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.utils.setTimeout;
	
	import model.Image;

	public class Title extends Sprite
	{
		private var image:Image;
		public static const COMPLETE:String = "complete";
		public function Title()
		{
			super();
			image = new Image("assets/顶栏木条.png");
			image.addEventListener(Image.COMPLETE,onComplete)
			
		}
		
		protected function onComplete(event:Event):void
		{
			event.currentTarget.removeEventListener(Image.COMPLETE,onComplete);
			this.addChild(image);
			//dispatchEvent(new Event(Image.COMPLETE));
			x = 0;
			y = -height;
			TweenLite.to(this, 0.3, {y:0, ease:Cubic.easeOut});
			
		}
		
		/**
		 *隐藏这个模块 ,并从显示列表删除。
		 * 
		 */		
		public function meHide():void
		{			
			TweenLite.to(this, 0.5, {y:-height, ease:Cubic.easeOut});	
			setTimeout(removeMe,600);
			
		}		
		private function removeMe():void
		{						
			if(parent)
			{
				parent.removeChild(this);			
			}
		}
		
	}
}